package Thread_;

public class ThreadExit_ {
    public static void main(String[] args) throws InterruptedException {

        T t = new T();
        t.start();

        Thread.sleep(6000);
        t.setLoop(false);
    }
}

class T extends Thread{
    private boolean loop = true;

    public void setLoop(boolean loop) {
        this.loop = loop;
    }

    @Override
    public void run() {
        while (loop){
            System.out.println("T 运行中....");
        }
    }
}